import request from "@/utils/request"
import type { SkuData } from "../spu/types"
import type { SkuResponseData, SkuInfoData } from "./type"
enum API {
    ADDSKU_URL = "/admin/product/saveSkuInfo",
    // 获取所有sku
    GETALLSKU_URL = "/admin/product/list/",
    // 上架的接口
    SALE_URL = "/admin/product/onSale/",
    // 下架的接口
    CANCELSALE_URL = "/admin/product/cancelSale/",
    // 得到商品的信息，抽屉组件
    GETSKU_URL = "/admin/product/getSkuInfo/",
    // 删除sku
    DELETE_URL = "/admin/product/deleteSku/",
}
// 添加sku的方法
export const reqAddSku = (data: SkuData) => request.post<any, any>(API.ADDSKU_URL, data)
// 获取所有sku
export const reqGetAllSku = (page: number | string, limit: number | string) => request.get<any, SkuResponseData>(API.GETALLSKU_URL + `${page}/${limit}`)
// 上架的接口
export const reqSaleSku = (skuId: number | string) => request.get<any, any>(API.SALE_URL + skuId)
// 下架的接口
export const reqCancelSale = (skuId: number | string) => request.get<any, any>(API.CANCELSALE_URL + skuId)
// 得到商品的信息，抽屉组件
export const reqGetInfo = (skuId: number | string) => request.get<any, SkuInfoData>(API.GETSKU_URL + skuId)
// 删除sku
export const reqDeleteSku = (skuId: number | string) => request.delete<any, any>(API.DELETE_URL + skuId)
